import { BasicColumn, FormSchema } from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';

/**
 * 风险信息库-查询字段
 */
export const searchFormSchema: FormSchema[] = [
  {
    label: '进口产品名称',
    field: 'imports',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '检疫类型',
    field: 'quarantineType',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'quarantine_type',
      stringToNumber: true,
    },
    colProps: { span: 6 },
  },
  {
    label: '状态',
    field: 'condition',
    component: 'JDictSelectTag',
    componentProps: () => {
      return {
        options: [
          { label: '关闭', value: 0, key: '0' },
          { label: '开启', value: 1, key: '1' },
        ],
      };
    },
    colProps: { span: 6 },
  },
];
/**
 * 风险信息库-表格数据
 */
export const columns: BasicColumn[] = [
  {
    title: '序号',
    dataIndex: '',
    key: 'rowIndex',
    width: 60,
    align: 'center',
    customRender: ({ index }) => {
      return parseInt(index) + 1;
    },
  },
  {
    title: '进口产品名称',
    dataIndex: 'imports', //字段不对
    width: 120,
  },
  {
    title: '检疫类型',
    dataIndex: 'quarantineType',
    width: 100,
    customRender: ({ text }) => {
      switch (text) {
        case 1:
          return '植物';
        case 2:
          return '水果';
        case 3:
          return '粮食';
        case 4:
          return '木材';
      }
    },
  },
  {
    title: '检疫处理要求',
    dataIndex: 'quarantineTreatmentRequirement',
    width: 120,
  },
  {
    title: '食品安全要求',
    dataIndex: 'foodSafetyRequirements',
    width: 120,
  },
  {
    title: '生产设施要求',
    dataIndex: 'productionFacilityRequirements',
    width: 80,
  },
  {
    title: '企业注册要求',
    dataIndex: 'businessRegistrationRequirements',
    width: 100,
  },
  {
    title: '生产和出口要求',
    dataIndex: 'productionExportRequirements',
    width: 100,
  },
  {
    title: '植物检疫证书要求',
    dataIndex: 'phytosanitaryCertificateRequirements',
    width: 100,
  },
  {
    title: '进境检验检疫',
    dataIndex: 'entryInspectionQuarantine',
    width: 100,
  },
  {
    title: '允许的产地管理',
    dataIndex: 'originManagement',
    width: 100,
  },
  {
    title: '检疫性有害生物',
    dataIndex: 'quarantinePest',
    width: 100,
  },
  {
    title: '检验检疫依据',
    dataIndex: 'inspectionQuarantineBasis',
    width: 100,
  },
  {
    title: '不符合/不合格要求处理',
    dataIndex: 'unqualified',
    width: 100,
  },
  {
    title: '符合性审查',
    dataIndex: 'complianceReview',
    width: 100,
  },
  {
    title: '回顾性审查',
    dataIndex: 'retrospectiveReview',
    width: 100,
  },
  {
    title: '其他',
    dataIndex: 'rests',
    width: 100,
  },
  {
    title: '是否允许',
    dataIndex: 'allowable',
    width: 100,
    customRender: ({ text }) => {
      return render.renderDictNative(
        text,
        [
          { label: '否', value: '0', color: 'red' },
          { label: '是', value: '1', color: 'green' },
        ],
        true
      );
    },
  },
  {
    title: '状态',
    dataIndex: 'condition',
    width: 100,
    customRender: ({ text }) => {
      return render.renderDictNative(
        text,
        [
          { label: '关闭', value: '0' },
          { label: '开启', value: '1', color: 'green' },
        ],
        true
      );
    },
  },
];
/**
 * 风险信息库-表单数据
 */
export const formSchema: FormSchema[] = [
  {
    label: '进口产品名称',
    field: 'imports',
    component: 'Input',
  },
  {
    label: '检疫类型',
    field: 'quarantineType',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'quarantine_type',
      stringToNumber: true,
    },
  },
  {
    label: '检疫处理要求',
    field: 'quarantineTreatmentRequirement',
    component: 'Input',
  },
  {
    label: '食品安全要求',
    field: 'foodSafetyRequirements',
    component: 'Input',
  },
  {
    label: '生产设施要求',
    field: 'productionFacilityRequirements',
    component: 'Input',
  },
  {
    label: '企业注册要求',
    field: 'businessRegistrationRequirements',
    component: 'Input',
  },
  {
    label: '生产和出口要求',
    field: 'productionExportRequirements',
    component: 'Input',
  },
  {
    label: '植物检疫证书要求',
    field: 'phytosanitaryCertificateRequirements',
    component: 'Input',
  },
  {
    label: '进境检验检疫',
    field: 'entryInspectionQuarantine',
    component: 'Input',
  },
  {
    label: '允许的产地管理',
    field: 'originManagement',
    component: 'Input',
  },
  {
    label: '检疫性有害生物',
    field: 'quarantinePest',
    component: 'Input',
  },
  {
    label: '检验检疫依据',
    field: 'inspectionQuarantineBasis',
    component: 'Input',
  },
  {
    label: '不符合/不合格要求处理',
    field: 'unqualified',
    component: 'Input',
  },
  {
    label: '符合性审查',
    field: 'complianceReview',
    component: 'Input',
  },
  {
    label: '回顾性审查',
    field: 'retrospectiveReview',
    component: 'Input',
  },
  {
    label: '其他',
    field: 'rests',
    component: 'Input',
  },
  {
    label: '是否允许',
    field: 'allowable',
    component: 'RadioGroup',
    defaultValue: 1,
    componentProps: () => {
      return {
        options: [
          { label: '否', value: 0, key: '0' },
          { label: '是', value: 1, key: '1' },
        ],
      };
    },
  },
  {
    label: '状态',
    field: 'condition',
    component: 'RadioGroup',
    defaultValue: 1,
    componentProps: () => {
      return {
        options: [
          { label: '关闭', value: 0, key: '0' },
          { label: '开启', value: 1, key: '1' },
        ],
      };
    },
  },
];
